package dk.degofedal.scala.math

class Fibonacci {

	def fib_recursive(value : Int):Int = {
		value match {
			case 0 => 0
			case 1 => 1
			case _ => fib_recursive(value-2) + fib_recursive(value-1)
		}
	}
	
	def fib_linear(value : Int, tmp : List[Int]):Int = {
		if (value == tmp.length - 1){
			return tmp.head
		}
		fib_linear(value, (tmp.head + tmp.tail.head) :: tmp)
	}
	
}